package org.itboys.core.service.mysql.front;

import org.itboys.admin.service.lasted.SundayUploadService;
import org.itboys.core.entity.mysql.SundayInStoreOrder;
import org.itboys.core.entity.mysql.SundayInStoreOrderSKU;
import org.itboys.core.util.NumberUtil;
import org.itboys.mysql.service.BaseMySqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author：贾琦磊
 * @Date：2018/8/16
 * @Description：入库单service
 */
@Service
public class SundayFrontInStoreOrderService extends BaseMySqlService<SundayInStoreOrder> {
    @Autowired
    private SundayUploadService uploadService;
    @Autowired
    private SundayInStoreOrderSKUService inStoreOrderSKUService;

    /**
     * 入库单生成方法，用户退货，仓库进货时调用,同时将需要保存的附表一并保存
     * @param inStoreOrder
     */
    @Transactional(rollbackFor = Exception.class)
    public void save(SundayInStoreOrder inStoreOrder, List<SundayInStoreOrderSKU> inStoreOrderSKUS){
        inStoreOrder.setNumber(NumberUtil.generateNumber("INSTORE"));
        super.insert(inStoreOrder);
        inStoreOrderSKUService.saveAll(inStoreOrderSKUS);

        }
}
